﻿<!doctype html>
<html>
	<head>
		<title></title>
        <script type="text/javascript" src="../assets/js/jquery-1.5.1.min.js"></script>   
        <script type="text/javascript" src="../assets/js/jquery-ui-1.8.14.custom.min.js"></script>   
        
        <script src="../assets/js/vm/CommandInfo.js"></script>
        <script src="../assets/js/vm/StackEntry.js"></script>
        <script src="../assets/js/vm/EvaluationStack.js"></script>
        <script src="../assets/js/vm/LocalMemory.js"></script>
        <script src="../assets/js/vm/MethodState.js"></script>
        <script src="../assets/js/vm/commands.js"></script>
        <script src="../assets/js/vm/vm.js"></script>
        
        <script src="terminal.js"></script>
        <link rel="stylesheet" href="terminal.css"/>

        <script>
            var vm = new VM();

            executeCommand = function (commandInput) {
                if (commandInput == "reset") {
                    vm = new VM();
                    return "";
                }

                try {
                    vm.Execute(commandInput);
                    var slot = vm.State.Stack.Top();
                    if (!slot)
                        return "Evaluation stack empty";

                    return "Type: " + slot.Type + "<br />Value: " + slot.Value;
                }
                catch (ex) {
                    return ex.toString();
                }

            };
            
            var console = new Terminal(executeCommand);

            $(document).ready(function () {
                console.Focus();
                
                $(document).click(function () {
                    console.Focus();
                });
            });

            handleInput = function () {
                if (event.keyCode == 13)
                    console.ExecuteCommand();
            };
        
        </script>

	</head>
	<body>

        <div id="console">
            <div id="prompt">
                <span class="promptPrefix"></span><input type="text" id="consoleInput" class="prompt" onkeydown="handleInput()"/>
            </div>
        </div>

        
        <div id="templates" style="visibility: hidden;display:none">
        
            <div id="lineItemTemplate" class="lineItem">
                <span class="promptPrefix"></span><span class="echoCommand"></span>
                <div class="consoleOutput"></div>
            </div>
        
            


        </div>

	</body>
</html>
